package com.blb.controller;

import com.blb.entity.Company;
import com.blb.entity.User;
import com.blb.service.IUserService;
import com.blb.utils.ShiroUtils;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.Map;

@Controller
@RequestMapping("userinfo")
public class UserInfoController {


    @Resource
    private IUserService userService;


    @RequestMapping("")
    public String getUserInfo(Model model){

        User user = ShiroUtils.getUser();

        Map<String, Object> userAndCompany = userService.getUserAndCompanyByUser(user.getId());

        model.addAttribute("userinfo",user);



        return "system/personal_data";
    }

    @PostMapping("update")
    public String updateInfo(User user){

        //获得登录者的id
        User user1 = ShiroUtils.getUser();
        String userId = user1.getId();

        user.setId(userId);

        userService.updateById(user);

        return "system/Integral_mall";
    }




}
